using Bzstd.Entity;
using Bzstd.Service;
using Bzstd.Utility;
using Microsoft.AspNetCore.Mvc;

namespace Bzstd.Controllers;

[ApiController, Route("api/{action}")]
public class SteamController(SteamService steamService) : ControllerBase
{
	[HttpGet, ActionName("gameInfo")]
	public GameInfo GetGameInfo()
	{
		return ConfigHelper.GameInfo;
	}

	[HttpGet, ActionName("init")]
	public void Init()
	{
		steamService.Init();
	}

	[HttpGet, ActionName("puzzleItems")]
	public List<PuzzleItem> GetWorkshopItems()
	{
		return steamService.PuzzleItems;
	}

	[HttpGet, ActionName("previewFile")]
	public object OpenPreviewFile()
	{
		return steamService.OpenPreviewFile();
	}

	[HttpGet, ActionName("mapFile")]
	public object OpenMapFile()
	{
		return steamService.OpenMapFile();
	}

	[HttpGet, ActionName("folder")]
	public object OpenFolder()
	{
		return steamService.OpenFolder();
	}

	[HttpPost, ActionName("submit")]
	public void Submit(PuzzleItem puzzleItem)
	{
		steamService.Submit(puzzleItem);
	}

	[HttpGet, ActionName("execCommand")]
	public void ExecCommand(string command)
	{
		steamService.ExecCommand(command);
	}

	[HttpGet, ActionName("showInWorkshop")]
	public void ShowInWorkshop(ulong fileId)
	{
		steamService.ShowInWorkshop(fileId);
	}

	[HttpGet, ActionName("showInLocalDirectory")]
	public void ShowInLocalDirectory(ulong fileId)
	{
		steamService.ShowInLocalDirectory(fileId);
	}

	[HttpGet, ActionName("queryWorkshopItem")]
	public PuzzleItem QueryWorkshopItem(ulong fileId)
	{
		return steamService.QueryWorkshopItem(fileId);
	}

	[HttpPost, ActionName("cloneMap")]
	public void CloneMap(PuzzleItem puzzleItem)
	{
		steamService.CloneMap(puzzleItem);
	}

	[HttpGet, ActionName("query")]
	public List<PuzzleItem> Query([FromQuery] QueryInfo queryInfo)
	{
		return steamService.Query(queryInfo);
	}

	[HttpGet, ActionName("operate")]
	public void Operate(ulong fileId, string type)
	{
		steamService.Operate(fileId, type);
	}
}
